<template>
    <div>
        <h1>医生信息</h1>
        <a href="/AddYS">新增医生</a>
        <br>
        <a href="/Jump">目录</a>
        <table class="table">
            <thead>
                <tr>
                    <td>姓名</td>
                    <td>头像</td>
                    <td>科室</td>
                    <td>创建日期</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="d in data">
                    <td>{{d.Dname}}</td>
                    
                    <td>
                        <img :src="'https://localhost:7292/'+d.Img" style="width: 60px;height: 60px;">
                    </td>
                    <td>{{d.DMname}}</td>
                    <td>{{moment(d.Dtimes).format("YYYY年MM月DD日")}}</td>
                    <td>
                        <input type="button" value="删除" class="btn btn-success" @click="shanc(d.DMid)">
                        <input type="button" value="编辑" class="btn btn-success" @click="bianj(d.DMid)">
                    </td>
                </tr>
            </tbody>
        </table>
        总共{{ Page.Count }}条 . 当前{{ tiaoj.PageIndex }}/{{ Page.PageCount }} 页 ,每页{{ tiaoj .PageSize }}条
        <br>
        <input type="button" value="首页" @click="ann(1)">
        <input type="button" value="上一页" @click="ann(2)">
        
        <input type="button" value="下一页" @click="ann(3)">
        <input type="button" value="尾页" @click="ann(4)">



    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { onMounted, ref } from 'vue';

onMounted(() => {
    xians();
});
const data = ref([
    {
      "Did": 0,
      "Mid": 0,
      "Img": "",
      "Dname": "",
      "Dtimes": "2025-05-19T02:17:39.487",
      "DMid": 0,
      "DMname": ""
    }
])
const tiaoj=ref({
    PageIndex:1,
    PageSize:3
})
const Page = ref({
    Count:0,
    PageCount:0
})
const xians = ()=>{
    axios.get("https://localhost:7292/api/Doctor/ShowYS",{params:tiaoj.value}).then(res=>{
        data.value=res.data.data
        Page.value.Count=res.data.count;
        Page.value.PageCount= Math.ceil(Page.value.Count/tiaoj.value.PageSize);
    })
}
/////////////分页////////////////////////////
const xxx = ()=>{}
const ann = (a:any)=>{
    if(a==1)
    {
        tiaoj.value.PageIndex=1;
        xians();
    }
    if(a==2)
    {
        if(tiaoj.value.PageIndex<=1)
        {
            alert("这是第一页ovo");
            return;
        }
        else
        {
            tiaoj.value.PageIndex-=1;
                    xians();
        }
    }
    if(a==3)
    {
        if(tiaoj.value.PageIndex>=Page.value.PageCount)
        {
            alert("这是最后一页了ovo");
            return;
        }
        else
        {
            tiaoj.value.PageIndex=tiaoj.value.PageIndex+1;
                    xians();
        }
        
    }
    if(a==4)
    {
        
        tiaoj.value.PageIndex=Page.value.PageCount;
        xians();
    }

}

</script>

<style scoped>

</style>